<?php
/***
服务器端获取微信的 getAccessToken 并且按照微信要求 统一获取 服务端缓存 7200 秒
***/$isnet = './#gac#';
$f = realpath($isnet );
$c = '';
if($f!==false){ 
  $ftime = filemtime( $f );
}
//var_dump($ftime);
$ctime = time();
//var_dump($ctime);
$ftime = bcsub($ctime,$ftime,0);
//var_dump($ftime);
if(abs($ftime) > 7201){
  $f = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxXXXXXXXX&secret=XXXXXXXXXX";
  header('isnet: YES');
}
$c = file_get_contents($f);
if($c==true && $f{0} !== '.'){
  //$cc = 
  file_put_contents($isnet,$c,LOCK_EX);
  //var_dump($cc);
}
echo $c;
